//引入第三方包express
var express = require('express')
var { expressjwt } = require('express-jwt')
// 实例化express
var app = express()

// 设置静态资源托管文件夹
app.use(express.static('state'))
// 设置post请求中间件
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.use(expressjwt({
    secret: '1234',
    algorithms: ['HS256']
}).unless({ path: ['/user/login', '/user/register'] }))
// 导入子路由
var userRouter = require('./user/user')
// 注册子路由
app.use('/user', userRouter)

// 监听
app.listen(8080, () => {
    console.log('服务器端');

})